package com.mocha.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * 使用WebFilter注解 定义Filter，但是要在App类上 添加 注解 @ServletComponentScan 扫描到此过滤器
 */
@WebFilter(urlPatterns = "/test",filterName = "webFilter")
public class TestFilterA implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

        System.out.println("TestFilterA do init");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("TestFilterA do Filter");
        filterChain.doFilter(servletRequest, servletResponse);

    }

    @Override
    public void destroy() {
        System.out.println("TestFilterA do destroy");
    }
}
